package com.zhijian.medical.controller;

import com.zhijian.medical.entity.vo.request.AchievementTechnologyTransformationSaveOrUpdateVo;
import com.zhijian.medical.entity.vo.request.AchievementTechnologyTransformationSearchVo;
import com.zhijian.medical.entity.vo.response.AchievementTechnologyTransformationVo;
import com.zhijian.medical.service.AchievementTechnologyTransformationService;
import com.zhijian.response.annotation.Response;
import com.zhijian.util.page.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 成果技术转化 控制层
 *
 * @author auto
 * @version 1.0
 * @date 2024-05-11 10:00:04
 */
@Slf4j
@Controller
@Api(tags = "成果技术转化")
public class AchievementTechnologyTransformationController {

    @Autowired
    private AchievementTechnologyTransformationService service;

    /**
     * 新增
     *
     * @param param
     * @return
     */
    @Response
    @PostMapping("/achievement/technology/transformation")
    @ApiOperation("新增")
    public boolean insert(@RequestBody AchievementTechnologyTransformationSaveOrUpdateVo param) {
        log.info("{} - {}| insert info", this.getClass().getSimpleName(), param);
        return service.save(param);
    }

    /**
     * 删除
     *
     * @param id
     * @return
     */
    @Response
    @DeleteMapping("/achievement/technology/transformation/{id}")
    @ApiOperation("删除")
    public boolean delete(@PathVariable("id") Long id) {
        log.info("{} - {}| delete info", this.getClass().getSimpleName(), id);
        service.deleteById(id);
        return true;
    }

    /**
     * 修改
     *
     * @param id
     * @param param
     * @return
     */
    @Response
    @PutMapping("/achievement/technology/transformation/{id}")
    @ApiOperation("修改")
    public boolean update(@PathVariable("id") Long id, @RequestBody AchievementTechnologyTransformationSaveOrUpdateVo param) {
        log.info("{} - {}| update info, {}", this.getClass().getSimpleName(), id, param);
        param.setId(id);
        return service.modify(param);
    }

    /**
     * 根据id查询
     *
     * @param id
     * @return
     */
    @Response
    @GetMapping("/achievement/technology/transformation/{id}")
    @ApiOperation("根据id查询")
    public AchievementTechnologyTransformationVo selectById(@PathVariable("id") Long id) {
        log.info("{} - {}| query info", this.getClass().getSimpleName(), id);
        return service.selectVoById(id);
    }

    /**
     * 分页查询
     *
     * @param param
     * @return
     */
    @Response
    @PostMapping("/achievement/technology/transformation/page")
    @ApiOperation("分页查询")
    public Page<AchievementTechnologyTransformationVo> selectByCondition(@RequestBody(required = false) AchievementTechnologyTransformationSearchVo param) {
        if (param == null)
            param = AchievementTechnologyTransformationSearchVo.builder().build();
        log.info("{} - {}| query info", this.getClass().getSimpleName(), param);
        return service.selectPage(param);
    }

    /**
     * 列表查询
     *
     * @param param
     * @return
     */
    @Response
    @PostMapping("/achievement/technology/transformation/list")
    @ApiOperation("列表查询")
    public List<AchievementTechnologyTransformationVo> selectList(@RequestBody(required = false) AchievementTechnologyTransformationSearchVo param) {
        if (param == null)
            param = AchievementTechnologyTransformationSearchVo.builder().build();
        log.info("{} - {}| query info", this.getClass().getSimpleName(), param);
        return service.selectList(param);
    }

    /**
     * 批量删除
     *
     * @param idList
     * @return
     */
    @Response
    @DeleteMapping("/achievement/technology/transformation/list")
    @ApiOperation("批量删除")
    public boolean delete(@RequestBody(required = false) List<Long> idList) {
        log.info("{} - {}| delete info", this.getClass().getSimpleName(), idList);
        service.deleteByIdList(idList);
        return true;
    }

}